#include "EditorNoticationStatusViewModel.h"
#include "EditorNoticationStatusModel.h"
#include "StatusBar/EditorStatusItemModel.h"

#include "Asset/EditorDefaultPackage.h"

#include "Window/EditorMainWindowModel.h"
#include "Window/EditorWindowGroupModel.h"
#include "Notification/EditorNotificationModel.h"


void REditorNoticationStatusViewModel::BindModel(TSharedObjectPtr<REditorStatusItemModel> InModel)
{
    Super::BindModel(InModel);
    Model = InModel;

    NoNotificationIcon=REditorDefaultPackage::Get()->GetIcon(U"CodiconBell");
    NotificationIcon=REditorDefaultPackage::Get()->GetIcon(U"CodiconBellDot");
    NotificationDontDisturbIcon=REditorDefaultPackage::Get()->GetIcon(U"CodiconBellSlashDot");
    NoNotificationDontDisturbIcon=REditorDefaultPackage::Get()->GetIcon(U"CodiconBellSlash");
}

TSharedObjectPtr<RTexture2D> REditorNoticationStatusViewModel::GetIcon() const
{
    if(HasNotification())
    {
        if(IsDonotDisturb())
        {
            return NotificationDontDisturbIcon;
        }
        return NotificationIcon;
    }

    if(IsDonotDisturb())
    {
        return NoNotificationDontDisturbIcon;
    }
    return NoNotificationIcon;   
}

void REditorNoticationStatusViewModel::OnClicked()
{
    REditorWindowGroupModel::Get()->MainWindow->GetNotification()->ToggleNotificationVisible();
}

bool REditorNoticationStatusViewModel::HasNotification() const
{
    return !REditorWindowGroupModel::Get()->MainWindow->GetNotification()->IsEmpty();
}

bool REditorNoticationStatusViewModel::IsDonotDisturb() const
{
    return REditorWindowGroupModel::Get()->MainWindow->GetNotification()->IsDontDisturb();
}
